package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.YdayGpc;
import com.stylefeng.guns.modular.system.service.IYdayGpcService;

/**
 * 昨日涨停控制器
 *
 * @author fengshuonan
 * @Date 2018-07-27 20:27:24
 */
@Controller
@RequestMapping("/ydayGpc")
public class YdayGpcController extends BaseController {

    private String PREFIX = "/system/ydayGpc/";

    @Autowired
    private IYdayGpcService ydayGpcService;

    /**
     * 跳转到昨日涨停首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "ydayGpc.html";
    }

    /**
     * 跳转到添加昨日涨停
     */
    @RequestMapping("/ydayGpc_add")
    public String ydayGpcAdd() {
        return PREFIX + "ydayGpc_add.html";
    }

    /**
     * 跳转到修改昨日涨停
     */
    @RequestMapping("/ydayGpc_update/{ydayGpcId}")
    public String ydayGpcUpdate(@PathVariable Integer ydayGpcId, Model model) {
        YdayGpc ydayGpc = ydayGpcService.selectById(ydayGpcId);
        model.addAttribute("item",ydayGpc);
        LogObjectHolder.me().set(ydayGpc);
        return PREFIX + "ydayGpc_edit.html";
    }

    /**
     * 获取昨日涨停列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return ydayGpcService.selectList(null);
    }

    /**
     * 新增昨日涨停
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(YdayGpc ydayGpc) {
        ydayGpcService.insert(ydayGpc);
        return SUCCESS_TIP;
    }

    /**
     * 删除昨日涨停
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer ydayGpcId) {
        ydayGpcService.deleteById(ydayGpcId);
        return SUCCESS_TIP;
    }

    /**
     * 修改昨日涨停
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(YdayGpc ydayGpc) {
        ydayGpcService.updateById(ydayGpc);
        return SUCCESS_TIP;
    }

    /**
     * 昨日涨停详情
     */
    @RequestMapping(value = "/detail/{ydayGpcId}")
    @ResponseBody
    public Object detail(@PathVariable("ydayGpcId") Integer ydayGpcId) {
        return ydayGpcService.selectById(ydayGpcId);
    }
}
